/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-26
 * Time: 19:30
 */

class UserError extends Exception{
    public UserError(String message){
        super(message);
    }
}

class PassWordError extends Exception{
    public PassWordError(String message){
        super(message);
    }
}

public class Test03 {
    private static String userName = "admin";
    private static String passWord = "123456";

    public static void main(String[] args) {
        try {
            login("admin","123456");
        } catch (UserError userError) {
            userError.printStackTrace();
        } catch (PassWordError passWordError) {
            passWordError.printStackTrace();
        }
    }

    public static void login(String userName, String passWord) throws UserError, PassWordError {
        if (!Test03.userName.equals(userName)) {
            throw new UserError("用户名错误");
        }
        if (!Test03.passWord.equals(passWord)) {
            throw new PassWordError("密码错误");
        }
        System.out.println("登陆成功");
    }

}
